package com.manor.paradise.activity

import android.content.Context
import android.content.Intent
import android.graphics.Color
import androidx.viewpager.widget.ViewPager
import com.manor.common.activity.AbsActivity
import com.manor.common.utils.KLog
import com.manor.paradise.R
import com.manor.paradise.adapter.CommonPagerAdapter
import com.manor.paradise.fragment.GiveInfoFragment
import kotlinx.android.synthetic.main.activity_gice_info.*


/**
 * 转赠明细
 */
class GiveInfoActivity : AbsActivity() {

    private var older_int = 0

    companion object {

        fun forward(context: Context) {
            val intent = Intent(context, GiveInfoActivity::class.java)
            context.startActivity(intent)
        }
    }

    override fun getLayoutId(): Int {
        return R.layout.activity_gice_info
    }

    override fun main() {
        super.main()

        val pagerAdapter = CommonPagerAdapter(supportFragmentManager, GiveInfoFragment(mContext,0), GiveInfoFragment(mContext,1))//, ExchangePropsFragment(mContext)
        viewpager.offscreenPageLimit = 1
        viewpager.adapter = pagerAdapter
        viewpager.addOnPageChangeListener(object : ViewPager.SimpleOnPageChangeListener() {
            override fun onPageSelected(position: Int) {
                setViewpagershow(position)
            }

            override fun onPageScrollStateChanged(state: Int) {
                super.onPageScrollStateChanged(state)
                KLog.e("tag", state.toString() + "")
            }
        })
        im_back.setOnClickListener { finish() }
        tv_zc.setOnClickListener {
            viewpager.currentItem = 0
        }
        tv_js.setOnClickListener {
            viewpager.currentItem = 1
        }
    }

    private fun setViewpagershow(tv: Int) {
        if(tv==0){
            tv_zc.setTextColor(Color.parseColor("#50D8FF"))
            tv_js.setTextColor(Color.parseColor("#ffffff"))
        } else {
            tv_js.setTextColor(Color.parseColor("#50D8FF"))
            tv_zc.setTextColor(Color.parseColor("#ffffff"))
        }

        older_int = tv
    }

    override fun onDestroy() {
        super.onDestroy()

    }
}
